const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin')

module.exports = (key) => {
  return {
    mode: 'development',
    entry: path.resolve(__dirname, 'main.js'),
    output: {
      path: path.resolve(__dirname, `../../dist/${key}`),
      filename: `${key}.bundle.js`,
    },
    module: {
      rules: [
        { test: /\.vue/, use: 'vue-loader' },
        { test: /\.css/, use: ['style-loader', 'css-loader'] },
      ],
    },
    plugins: [
      new VueLoaderPlugin(),
      new HtmlWebpackPlugin({
        filename: `${key}.html`,
        template: path.resolve(__dirname, './index.html'),
      })
    ]
  }
}
